/**
 * 郭楠project
 * com.gn.service
 * CommentServiceImpl.java
 * 创建人:TonyGuo 
 * 时间：2016年12月14日-下午10:18:20 
 * 2016Tm公司-版权所有
 */
package com.gn.service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.gn.dao.CommentDao;
import com.gn.entity.Comment;
import com.gn.util.CommonUtils;
import com.gn.util.IdUtils;

/**
 * 
 * CommentServiceImpl
 * 创建人:TonyGuo
 * 时间：2016年12月14日-下午10:18:20 
 * @version 1.0.0
 * 
 */
@Service
public class CommentServiceImpl implements CommentService{
	@Resource
	CommentDao commentDao;

	@Override
	public void addUserComment(Comment comment) {
		comment.setId(IdUtils.uuid());
		comment.setCommentDatetime(CommonUtils.date2Str(new Date()));
		commentDao.addUserComment(comment);
	}

	@Override
	public void deleteUserComment(String id) {
		commentDao.deleteUserComment(id);
	}

	@Override
	public Comment findUserComment(String id) {
		return commentDao.findUserComment(id);
	}

	@Override
	public List<Comment> findUserCommentList(String uid) {
		return commentDao.findUserCommentList(uid);
	}

	@Override
	public List<Comment> findAllUserCommentsById(Map<String, Object> map) {
		return commentDao.findAllUserCommentsById(map);
	}

	@Override
	public boolean addZanCount(String id) {
		String zanCount="";
		Comment c=commentDao.findUserComment(id);
		if(c!=null)zanCount=c.getZanCount();
		Integer count=Integer.valueOf(zanCount);
		count+=1;
		return commentDao.addZanCount(String.valueOf(count), id);
	}

	@Override
	public boolean addPaiZhuanCount(String id) {
		String paizhuanCount="";
		Comment c=commentDao.findUserComment(id);
		if(c!=null)paizhuanCount=c.getPaizhuanCount();
		Integer count=Integer.valueOf(paizhuanCount);
		count+=1;
		return commentDao.addPaiZhuanCount(String.valueOf(count), id);
	}

	/* (non-Javadoc)
	 * @see com.gn.service.CommentService#findGoodsCommentCount(java.lang.String)
	 */
	@Override
	public Integer findGoodsCommentCount(String gid) {
		// TODO Auto-generated method stub
		return commentDao.findGoodsCommentCount(gid);
	}

}
